import { AutoGuideStepBase } from "./AutoGuideStepBase";
import { IAutoGuideSteper } from "./IAutoGuideSteper";
import { AutoGuideData } from "../AutoGuideData";
import { Window } from "../../../../../component/window/Window";
import { AutoGuideType } from "../AutoGuideType";
import { Game } from "../../../../Game";
import { CallLater } from "../../../../../common/net/CallLater";
import { Dispatcher } from "../../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../../events/DataEvent";
import { EventName } from "../../../../mvc/EventName";
//class AutoGuideTimerSteper
    
    export  class AutoGuideTimerSteper extends AutoGuideStepBase implements IAutoGuideSteper
    {
        constructor()
        {
            super();
            return;
        }

        public guide(arg1: AutoGuideData, arg2: Window=null): void
        {
            if (this._timer != null) 
            {
                return;
            }
            if (arg1 == null || !(arg1.guideType == AutoGuideType.Timer)) 
            {
                return;
            }
            Game.scene.mouseEnabled = false;
            _data = arg1;
            this._timer = new Object /* flash.utils.Timer */(int(arg1.guideTypeValue), 1);
            this._timer.addEventListener(flash.events.TimerEvent.TIMER_COMPLETE, this.timerCompleteHandler);
            this._timer.start();
            return;
        }

        /* internal  */timerCompleteHandler(arg1: Object /* flash.events.TimerEvent */): void
        {
            if (this._timer == null) 
            {
                return;
            }
            Game.scene.mouseEnabled = true;
            this._timer.stop();
            this._timer = null;
            CallLater.addCallBack(this.nextFrame);
            return;
        }

        /* internal  */nextFrame(): void
        {
            if (_data == null) 
            {
                return;
            }
            Dispatcher.dispatchEvent(new DataEvent(EventName.AutoGuideStepEnd, _data));
            return;
        }

        public stop(arg1: AutoGuideData=null): void
        {
            return;
        }

        /* internal */ /* var */_timer: Object /* flash.utils.Timer */;
    }
